import { Injectable } from '@angular/core';
import { BaseService } from '../base/base.service';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class CartService extends BaseService {
  // 购物车数量
  public cartNum$(tableId: string): Observable<any> {
    return this.get(`front/cart/cart_num/${tableId}`);
  }

  // 加入购物车
  public addCart$(data: { [propsName: string]: any }): Observable<any> {
    return this.post('front/cart', data);
  }

  // 购物车列表
  public cartList$(tableId: string): Observable<any> {
    return this.get(`front/cart/${tableId}`);
  }

  // 修改购物车商品数量
  public changeCartNum$(data: { [propsName: string]: any }): Observable<any> {
    return this.post('front/cart/change_cart', data)
  }
}
